<template>
  <div>
  <van-nav-bar
      title=""
      left-text="Return"
      left-arrow
      @click-left="tzback()"
  />
    <van-cell-group inset>
      <van-field
          v-model="message"
          rows="1"
          autosize
          label="写个评价吧"
          type="textarea"
          placeholder="请写入您的评价"
      />
    </van-cell-group>
    <div>
      <van-button color="linear-gradient(to right, #ff6034, #ee0a24)" @click="commit">
        发布
      </van-button>
    </div>
  </div>

</template>

<script>
import {Toast} from "vant";

export default {
  name: "CommentWrite",
  data(){
    return{
      message:"",
    }
  },
  methods:{
    tzback(){
      var mid=this.$route.query.mid;
      this.$router.push({path:"/bathDetail",query:{mid:mid}});
    },
    commit(){
      console.log(this.message);
      var mid=this.$route.query.mid;
      console.log(mid)
      this.axios.get("http://localhost:8081/api/content/insert.do?content="+this.message+"&mid="+mid).then((res) => {
        if(res.data.code==200){
          //成功
          Toast('发布成功！');
          this.$router.push({path:"/bathDetail"});
        }else{
          //失败
          Toast('亲，网络异常！');
        }
      })
    }
  }
}
</script>

<style scoped>
.star{
  margin-right: 10em;
}
.input{
  margin-right: 10em;
  margin-top: 15px;
}
</style>